package com.java0.db;

import com.java0.db.entity.User;
import com.java0.db.repository.UserRepository;
import com.java0.db.service.ExampleService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.sql.SQLException;

/**
 *  使用shardingsphere-jdbc 实现读写分离
 */
@SpringBootApplication
public class ShardingSphereApplication {

    public static void main(String[] args) throws SQLException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ShardingSphereApplication.class, args);
        UserRepository repository = applicationContext.getBean(UserRepository.class);
        System.out.println(repository.selectAll());
        User user = new User();
        user.setId(1234L);
        repository.insert(user);
    }

}
